using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class BridMove : MonoBehaviour
{
    public bool ifLeave;
    private Vector2 stopPosition=new(-5f,2.5f);
    private Vector2 destoryPosition=new(20f,2.5f);
    // Start is called before the first frame update
    void Start()
    {
        gameObject.transform.position=new Vector2(-12f,2.5f);
    }

    // Update is called once per frame
    void Update()
    {
        Vector2 bridPosition=gameObject.transform.position;
        if(bridPosition.x<stopPosition.x)
        {
            gameObject.transform.Translate(Vector2.right / 20);
        }
        if(ifLeave)
        {
            gameObject.transform.Translate(Vector2.right / 20);
            if(bridPosition.x>destoryPosition.x)
            {
                Destroy(gameObject);
            }
        }
    }
}
